package com.fit.pages;

import java.util.LinkedList;

import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.OnEvent;

import com.fit.beans.MaterialBean;
import com.fit.interfaces.Buy;

public class Material {
	
	private String MaterialType = "Type of material: ";
	private String MaterialModel = "Model of material: ";
	private String MaterialShortDescription = "Short description material: ";
	
	@InjectPage
	private ViewMaterial viewMaterial;
	
	@InjectPage
	private Error errorPage;
	
	@OnEvent (value="submit", component="MaterialInputForm")
	Object onFromSubmit() {
		MaterialBean materialW = new MaterialBean();
		materialW.setBuy(new LinkedList<Buy>());
		materialW.setType(MaterialType);
		materialW.setModel(MaterialModel);
		materialW.setShortDescription(materialShortDescription);
		if (watchW.getType()==null || watchW.getModel()==null) {
            errorPage.setError("Nije moguce dodati novu knjigu bez naslova ili autora knjige!");
            return errorPage;
	}
		viewMaterial.setSingleMaterial(materialW);
        return viewMaterial;
        }


	public String getMaterialType() {
		return MaterialType;
	}
	
	public void setMaterialType(String watchType) {
		this.MaterialType = watchType;
	}

	public String getMaterialModel() {
		return Model;
	}

	public void setMaterialModel(String MaterialModel) {
		this.MaterialModel = MaterialModel;
	}

	public String getMaterialShortDescription() {
		return MaterialShortDescription;
	}

	public void setMaterialShortDescription(String MaterialShortDescription) {
		this.MaterialShortDescription = MaterialShortDescription;
	}

}
